package com.college.heyuhua.homecontroller;

import com.college.heyuhua.entity.Newsinfo;
import com.college.heyuhua.service.INewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by 赵东坡 on 2018/12/30.
 * Time:19:43
 * 宇宙无敌赵牛逼，祈求永无bug
 */
@Controller
@RequestMapping("/home")
public class IndexController {

    @Autowired
    private INewService iNewService;

    @RequestMapping("/index")
    public String index(ModelMap modelMap) {
        //TODO 获取redis中的数据
        List<Newsinfo> newsinfoList = iNewService.homepagefour();
        if(newsinfoList.size() >0 && newsinfoList != null) {
            modelMap.put("newsinfoList",newsinfoList.subList(0,4));
        }
        else{
            modelMap.put("message","获取新闻资讯失败，请在页面下方联系管理员！！！ 感谢配合");
        }
        return "home";
    }
}
